class Tour < ActiveRecord::Base
  belongs_to :school
  has_many :participations, :dependent => :destroy
  has_many :participators, :through => :participations, :source => :user do
    def leader
      find :first, :order => 'created_at asc'
    end
  end
  #has_many :discussions, :class_name => 'TourComment', :dependent => :destroy
  #has_one :program, :dependent => :destroy
  
  def editable_by?(user)
    user && (user.id == participators.leader.id)
  end
end
